package one.three.nineteen;

public class DeleteTail {

	private static class Node<Item> {
		private Item item;
		private Node next;
	}

	private static void deleteTail(Node first) {
		Node c = first;
		while (c.next.next != null) {
			c = c.next;
		}

		c.next = null;
	}

	public static void main(String[] args) {
		Node<String> f = new Node<String>();
		f.item = "0";
		Node<String> c = f;
		for (int i = 1; i <= 10; i++) {
			c.next = new Node<String>();
			c.next.item = i + "";
			c = c.next;
		}

		c = f;
		while (c != null) {
			System.out.println(c.item);
			c = c.next;
		}

		deleteTail(f);
		c=f;
		while (c != null) {
			System.out.println(c.item);
			c = c.next;
		}

	}

}
